<!DOCTYPE html>
<html>
<head>
	<title>代码生成器</title>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

	<!-- 样式 -->
	<link rel="stylesheet" href="css/bootstrap.min.css">
	<link rel="stylesheet" href="css/font-awesome.min.css">
	<link rel="stylesheet" href="plugins/jqgrid/ui.jqgrid-bootstrap.css">
	<link rel="stylesheet" href="css/main.css">

	<!-- 脚本 -->
	<script src="libs/jquery.min.js"></script>
	<script src="plugins/layer/layer.js"></script>
	<script src="libs/bootstrap.min.js"></script>
	<script src="libs/vue.min.js"></script>
	<script src="plugins/jqgrid/grid.locale-cn.js"></script>
	<script src="plugins/jqgrid/jquery.jqGrid.min.js"></script>
	<script src="js/common.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

	<style>
		body {
			background: #f8f9fa;
			font-family: "Microsoft YaHei", Arial, sans-serif;
			padding: 30px;
		}
		.card {
			background: #fff;
			border-radius: 10px;
			box-shadow: 0 4px 10px rgba(0,0,0,0.1);
			padding: 20px;
		}
		.card-header {
			font-size: 20px;
			font-weight: bold;
			margin-bottom: 15px;
			border-bottom: 2px solid #007bff;
			padding-bottom: 10px;
			color: #007bff;
		}
		.grid-btn {
			display: flex;
			align-items: center;
			gap: 10px;
			margin-bottom: 15px;
		}
		.grid-btn .form-control {
			max-width: 200px;
			border-radius: 20px;
		}
		.btn {
			border-radius: 20px;
			padding: 6px 16px;
		}
		#jqGrid {
			margin-top: 10px;
		}
	</style>
</head>
<body>
<div id="rrapp" class="container">
	<div class="card">
		<div class="card-header">
			<i class="fa fa-cogs"></i> 代码生成器
		</div>
		<div class="grid-btn">
			<input type="text" class="form-control" v-model="q.tableName"
				   @keyup.enter="query" placeholder="请输入表名">
			<a class="btn btn-secondary" @click="query">
				<i class="fa fa-search"></i> 查询
			</a>
			<a class="btn btn-primary" @click="generator">
				<i class="fa fa-file-code-o"></i> 生成代码
			</a>
		</div>
		<table id="jqGrid"></table>
		<div id="jqGridPager"></div>
	</div>
</div>
<!--<script>-->
<!--	new Vue({-->
<!--		el: '#rrapp',-->
<!--		data: {-->
<!--			q: {-->
<!--				tableName: ''-->
<!--			},-->
<!--			dbConfig: JSON.parse(localStorage.getItem('dbConfig')) || {},-->
<!--			codeConfig: JSON.parse(localStorage.getItem('codeConfig')) || {}-->
<!--		},-->
<!--		methods: {-->
<!--			query() {-->
<!--				if (!this.q.tableName) {-->
<!--					alert('请输入表名');-->
<!--					return;-->
<!--				}-->
<!--				// 调用后端查询表信息接口，需要把数据库配置传过去-->
<!--				axios.post('/generator/queryTable', {-->
<!--					tableName: this.q.tableName,-->
<!--					dbConfig: this.dbConfig-->
<!--				}).then(res => {-->
<!--					console.log(res.data);-->
<!--					// TODO: 渲染 jqGrid 表格-->
<!--				}).catch(err => {-->
<!--					alert('查询失败: ' + err);-->
<!--				});-->
<!--			},-->
<!--			generator() {-->
<!--				if (!this.q.tableName) {-->
<!--					alert('请输入表名');-->
<!--					return;-->
<!--				}-->
<!--				// 调用后端生成代码接口，把数据库和生成器配置都传过去-->
<!--				axios.post('/generator/generateCode', {-->
<!--					tables: [this.q.tableName],-->
<!--					dbConfig: this.dbConfig,-->
<!--					codeConfig: this.codeConfig-->
<!--				}, { responseType: 'blob' })-->
<!--						.then(res => {-->
<!--							const blob = new Blob([res.data]);-->
<!--							const link = document.createElement('a');-->
<!--							link.href = window.URL.createObjectURL(blob);-->
<!--							link.download = 'renren.zip';-->
<!--							link.click();-->
<!--						}).catch(err => {-->
<!--					alert('生成失败: ' + err);-->
<!--				});-->
<!--			}-->
<!--		}-->
<!--	});-->
<!--</script>-->

<script src="js/generator.js?v=20250820"></script>
</body>
</html>
